import { ElMessageBox } from 'element-plus'
import { ref } from 'vue'

export default function () {
  const havingSelectList = ref<any[]>([])
  function addHavingSelect () {
    havingSelectList.value.push({
      field: [],
      logic: 'AND',
      operator: '=',
      valueA: '',
      order: 0,
      valueB: ''
    })
  }

  function deleteHavingSelect (index: number) {
    ElMessageBox.confirm('你确定要删除这条条件吗？', '提示', {
      type: 'warning'
    })
      .then(() => {
        havingSelectList.value.splice(index, 1)
      })
      .catch(() => {})
  }

  return {
    havingSelectList,
    addHavingSelect,
    deleteHavingSelect
  }
}
